<?php

namespace app\api\controller\meet\article;

use app\common\controller\Api;

/**
 * 分类接口
 */
class Category extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     *
     * @var \app\common\model\meet\article\Category
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();

        $this->model = new \app\common\model\meet\article\Category();
    }

    public function index()
    {
        $tabList = [
            ['id' => 0, 'name' => '全部'],
        ];

        $condition = [
            'status' => $this->model::STATUS_NORMAL
        ];

        $list = $this->model->where($condition)->field('id,name')->order('weigh', 'desc')->select();

        if ($list) {
            foreach ($list as $key) {
                $tabList[] = ['id' => $key['id'], 'name' => $key['name']];
            }
        }

        $this->success('', ['list' => $tabList]);
    }
}
